"use strict";
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
    var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
    if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
    else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
    return c > 3 && r && Object.defineProperty(target, key, r), r;
};
var __param = (this && this.__param) || function (paramIndex, decorator) {
    return function (target, key) { decorator(target, key, paramIndex); }
};
/**
 * 需配置tsconfig："experimentalDecorators": true,
 * @ClassDecorator 装饰器(Decorator)是一种特殊的类型声明，可以附加在
 * 类、方法、属性、参数上，装饰器是一个函数
 */
const doc = (target) => {
    target.prototype.name = 'newking';
};
/**
 *  @doc相当于doc(Xiaohong)  @用来接受一个装饰器
 *  让装饰器帮忙设置 Xiaohong 的属性，就不用去干扰 Xiaohong 这个类
 */
let Xiaohong = class Xiaohong {
};
Xiaohong = __decorate([
    doc
], Xiaohong);
// const xh:any = new Xiaohong();
// console.log(xh.name);
/**
 * 上面是类装饰器，接下来了解下属性装饰器和方法装饰器
 * 此时的target就不是Class，而是原型对象
 * key返回名称
 */
const doc_p = (target, key) => {
    console.log('属性装饰器返回:', target, key);
};
/**
 * 方法装饰器，12参数同上，参数3返回一个描述对象
 * 参数3：descriptor.value 就是@doc_f 后面这个函数对象
 */
const doc_f = (target, key, descriptor) => {
    console.log('方法装饰器返回:', target, key, descriptor);
};
//参数装饰器 参数3：index表示参数所在位置[索引]
const doc_param = (target, key, index) => {
    console.log('参数装饰器返回:', target, key, index);
};
class P {
    constructor() { this.name = 'newking'; }
    getName(name, age) {
        console.log(this.name, name, age);
    }
}
__decorate([
    doc_p
], P.prototype, "name", void 0);
__decorate([
    doc_f,
    __param(1, doc_param)
], P.prototype, "getName", null);
